/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import interfaces.InternationalizableEntity;
import interfaces.InternationalizableEntityDescription;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author damfercer
 */
@Entity
@Table(name = "sex_description")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SexDescription.findAll", query = "SELECT s FROM SexDescription s"),
    @NamedQuery(name = "SexDescription.findByIdSexDescription", query = "SELECT s FROM SexDescription s WHERE s.idSexDescription = :idSexDescription"),
    @NamedQuery(name = "SexDescription.findByDescription", query = "SELECT s FROM SexDescription s WHERE s.description = :description")})
public class SexDescription implements Serializable,InternationalizableEntityDescription {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_SEX_DESCRIPTION")
    private Integer idSexDescription;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "DESCRIPTION")
    private String description;
    @JoinColumn(name = "ID_SEX", referencedColumnName = "ID_SEX")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Sex idSex;
    @JoinColumn(name = "ID_LANGUAGE", referencedColumnName = "ID_LANGUAGE")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Language idLanguage;

    public SexDescription() {
    }

    public SexDescription(Integer idSexDescription) {
        this.idSexDescription = idSexDescription;
    }

    public SexDescription(Integer idSexDescription, String description) {
        this.idSexDescription = idSexDescription;
        this.description = description;
    }

    public Integer getIdSexDescription() {
        return idSexDescription;
    }

    public void setIdSexDescription(Integer idSexDescription) {
        this.idSexDescription = idSexDescription;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Sex getIdSex() {
        return idSex;
    }

    public void setIdSex(Sex idSex) {
        this.idSex = idSex;
    }

    public Language getIdLanguage() {
        return idLanguage;
    }

    public void setIdLanguage(Language idLanguage) {
        this.idLanguage = idLanguage;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSexDescription != null ? idSexDescription.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SexDescription)) {
            return false;
        }
        SexDescription other = (SexDescription) object;
        if ((this.idSexDescription == null && other.idSexDescription != null) || (this.idSexDescription != null && !this.idSexDescription.equals(other.idSexDescription))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.SexDescription[ idSexDescription=" + idSexDescription + " ]";
    }

    @Override
    public InternationalizableEntity getEntity() {
       return getIdSex();
    }
    
}
